<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class Distribute extends RowAction
{
    /**
     * @return string
     */
    protected $title = '<i class="feather icon-at-sign"></i>';

    public function handle(Request $request)
    {
        return $this->response()
            ->redirect('/task/mng/create?todo_id=' . $this->getKey());
    }

    /**
     * @return string|array|void
     */
    public function confirm()
    {
        // return ['Confirm?', 'contents'];
    }

    /**
     * @param Model|Authenticatable|HasPermissions|null $user
     *
     * @return bool
     */
    protected function authorize($user): bool
    {
        return true;
    }

    /**
     * @return array
     */
    protected function parameters()
    {
        return [];
    }

    protected function html()
    {
        $this->defaultHtmlAttribute('href', 'javascript:void(0)');
        return <<<HTML
<a title="派发任务"  style="margin-right: 8px;" {$this->formatHtmlAttributes()}>{$this->title()}</a>
HTML;
    }
}